package com.itheima.dao;

import com.itheima.pojo.Tag;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface TagMapper extends Mapper<Tag> {

    @Select("SELECT * FROM t_tag WHERE `content` LIKE CONCAT('%',#{keyWord},'%')")
    List<Map> findAllByKeyword(String keyword);


    @Select("SELECT * FROM t_tag WHERE status = 1 ORDER BY click_count DESC")
    List<Tag> getTagSortByClickCount();

    //@Select("SELECT t.*,COUNT(b.tag_uid) FROM t_tag t,t_blog b WHERE t.`uid`=b.`tag_uid` GROUP BY tag_uid")
    @Select("SELECT * FROM t_tag WHERE status = 1 ORDER BY sort DESC")
    List<Tag> getTagSortByCite();

    @Select("SELECT MAX(sort) FROM t_tag")
    int getMaxSort();
}
